import request from "@/utils/request";

// 查询生产工单列表
export function listWorkorder(query) {
  return request({
    url: "/mes/pro/workorder/list",
    method: "get",
    params: query,
  });
}

//add begin by zyj 2024/10/17 产品名称支持模糊搜索下拉
export function getProductNameList(query) {
  return request({
    url: "/mes/pro/workorder/getProductNameList",
    method: "get",
    params: query,
  });
}

//add begin by zyj 2024/10/17 产品名称支持模糊搜索下拉

//同步工单数据
// export function getJdyWorkorder(query) {
//   return request({
//     url: "/mes/k3cloud/api/prdMo/syncPrdMo",
//     method: "get",
//     params: query,
//   });
// }

export function getJdyWorkorder(query) {
  return request({
    url: "/sync/k3cloud/api/proWorkorderSync/proWorkorderSync",
    method: "get",
    params: query,
  });
}

//同步委外工单数据
export function getJdyoutsourcing(query) {
  return request({
    url: "/mes/k3cloud/api/outsourcing/syncoutsourcing",
    method: "get",
    params: query,
  });
}

//add begin by zyj 2024/10/22 增加审核-获取routeid
export function getRouteId(workorderId) {
  return request({
    url: "/mes/pro/workorder/getRouteId/" + workorderId,
    method: "get",
  });
}

//add end by zyj 2024/10/22 增加审核-获取routeid

// 查询生产工单详细
export function getWorkorder(workorderId) {
  return request({
    url: "/mes/pro/workorder/" + workorderId,
    method: "get",
  });
}

//查询对应的序列号
export function getSerialList(query) {
  return request({
    url: "/mes/pro/routeproductbom/findSerialList",
    method: "get",
    params: query,
  });
}

// 生成入库单
export function getGenerateProductrecpt(id) {
  return request({
    url: "/mes/pro/report/generateProductrecpt/" + id,
    method: "get",
  });
}

// 新增生产工单
export function addWorkorder(data) {
  return request({
    url: "/mes/pro/workorder",
    method: "post",
    data: data,
  });
}

// 修改生产工单
export function updateWorkorder(data) {
  return request({
    url: "/mes/pro/workorder",
    method: "put",
    data: data,
  });
}

// 删除生产工单
export function delWorkorder(workorderId) {
  return request({
    url: "/mes/pro/workorder/" + workorderId,
    method: "delete",
  });
}

// 产线运行状态
export function WorkorderRunStatus(workorderId) {
  return request({
    url: "/mes/pro/workorder/updateRunStatus/" + workorderId,
    method: "put",
  });
}

// 查询物料依赖列表
export function listItems(query) {
  return request({
    url: "/mes/pro/workorder/listItems",
    method: "get",
    params: query,
  });
}

// 产品制程物料BOM 保存 doType=2
export function updateRouteOrLine(data) {
  return request({
    url: "/mes/pro/workorder/updateRouteOrLine",
    method: "put",
    data: data,
  });
}

// export function updateRouteOrLine(data) {
//   return request({
//     url: '/mes/pro/workorder/updateRouteOrLine',
//     method: 'put',
//     data: data
//   })
// }
// 产品制程物料BOM 保存 doType=1
export function addRouteproductbom(data) {
  return request({
    url: "/mes/pro/routeproductbom",
    method: "post",
    data: data,
  });
}

// 工艺维护
export function addRouteCommit(data) {
  return request({
    url: "/mes/pro/workorder/routeCommit",
    method: "put",
    data: data,
  });
}

//回写汇报单
export function morptmData(data) {
  return request({
    url: "/mes/k3cloud/api/MorptmData/saveToErp",
    method: "post",
    data: data,
  });
}

// 生成汇报单
export function generateReport(data) {
  return request({
    url: "/mes/pro/report/generateReportAndFqcQuality",
    method: "post",
    data: data,
  });
}

// 领料单列表
export function listIssueheader(query) {
  return request({
    url: "/mes/wm/issueheader/list",
    method: "get",
    params: query,
  });
}

// 补料列表
export function listSupply(query) {
  return request({
    url: "/mes/pro/supply/list",
    method: "get",
    params: query,
  });
}

// 补料列表
export function listBack(query) {
  return request({
    url: "/mes/pro/back/list",
    method: "get",
    params: query,
  });
}

// 查询领料数量
export function getReceivedNumByWorkorderId(workorderId) {
  return request({
    url: "/mes/wm/issueheader/getInfoByWorkorderId/" + workorderId,
    method: "get",
  });
}

// 汇报单列表
export function reportList(workorderId) {
  return request({
    url: "mes/pro/report/list/" + workorderId,
    method: "get",
  });
}

// 工艺维护列表
export function getProRouteItemlist(query) {
  return request({
    url: "/mes/pro/routeproductbom/getProRouteItemlist",
    method: "get",
    params: query,
  });
}

export function getProRouteItemlistNoPage(query) {
  return request({
    url: "/mes/pro/routeproductbom/getProRouteItemlistNoPage",
    method: "get",
    params: query,
  });
}

// /bom/list
export function getBomlist(query) {
  return request({
    url: "/mes/bom/list",
    method: "get",
    params: query,
  });
}

// 获取角色状态接口
export function selectUserRole(roleName) {
  return request({
    url: "/mes/pro/workorder/selectUserRole/" + roleName,
    method: "get",
  });
}

// 下推
export function pushDownWorkorder(data) {
  return request({
    url: "/mes/pro/workorder/pushDown",
    method: "put",
    data: data,
  });
}

// 申请延期
export function worderDelayTime(data) {
  return request({
    url: "/mes/pro/workorder/updateDelayTime",
    method: "put",
    data: data,
  });
}

//根据id选择bom模板
export function getBomtemplate(query) {
  return request({
    url: "/mes/bom/workorder/add/",
    method: "get",
    params: query,
  });
}

export function workorderPushList(query) {
  return request({
    url: "/mes/pro/workorderPushdown/list",
    method: "get",
    params: query,
  });
}

// 汇报单提交
export function editSubmit(data) {
  return request({
    url: "/mes/pro/report/editSubmit",
    method: "put",
    data: data,
  });
}

// 产线停产

export function workOrderStop(data) {
  return request({
    url: "/mes/pro/workorder/workOrderStop",
    method: "post",
    data: data,
  });
}

// 终止
export function finishOrder(data) {
  return request({
    url: "/mes/pro/workorder/finishOrder",
    method: "post",
    data: data,
  });
}

// 获取bom版本
export function getVersions(query) {
  return request({
    url: "/mes/pro/workorder/getVersions",
    method: "get",
    params: query,
  });
}

// 查询虚拟入库
export function getVirtualStokcinInfos(query) {
  return request({
    url: "/mes/pro/workorderSn/getVirtualStokcinInfos",
    method: "get",
    params: query,
  });
}

// 获取bom 列表
export function getMaterialInfoList(query) {
  return request({
    url: "/mes/pro/workorderbom/getMaterialInfoList",
    method: "get",
    params: query,
  });
}

// 获取bom 列表--新
export function getMaterialInfoList2(data) {
  return request({
    url: "/mes/pro/workorderbom/selectMdItemsForWorkorderBom",
    method: "post",
    data: data,
  });
}

// 部分退料信息
export function getMaterialListOfOldSubNew(query) {
  return request({
    url: "/mes/pro/workorderbom/getMaterialListOfOldSubNew",
    method: "get",
    params: query,
  });
}

// 部分退料信息--新
export function getMaterialListOfOldSubNew2(data) {
  return request({
    url: "/mes/pro/workorder/bomCompare",
    method: "post",
    data: data,
  });
}

// 全部退料
export function getMaterialInfoListOfCurrVersion(query) {
  return request({
    url: "/mes/pro/workorderbom/getMaterialInfoListOfCurrVersion",
    method: "get",
    params: query,
  });
}

// 整单打回
export function rejectWholeWorkOrder(query) {
  return request({
    url: "/mes/pro/workorder/beatBack",
    method: "get",
    params: query,
  });
}

// bom变更确定
export function changeBomVersion(data) {
  return request({
    url: "/mes/pro/workorder/changeBom",
    method: "post",
    data: data,
  });
}

//
export function selectBomLineList(id) {
  return request({
    url: "/mes/pro/workorder/selectBomLineList/" + id,
    method: "get",
  });
}

export function addProProductBack(data) {
  return request({
    url: "/mes/pro/workorder/addProProductBack",
    method: "post",
    data: data,
  });
}

//生成领料单
// export function addByErp(data) {
//   return request({
//     url: "/mes/wm/issueheader/addByErp ",
//     method: "post",
//     data: data,
//   });
// }
export function addByErp(data) {
  return request({
    url: "/sync/k3cloud/api/issueHeaderSync/issueHeaderSync",
    method: "post",
    data: data,
  });
}

//根据工单ID查询SN码 2024-11-27 djj
export function workorderSnList(query) {
  return request({
    url: "/mes/pro/workorderSn/list",
    method: "get",
    params: query,
  });
}

//提交改制申请 2024-11-27 djj
export function remake(data) {
  return request({
    url: "/mes/remake/product/remake",
    method: "post",
    data: data,
  });
}

//提交改制详情 2024-11-29 djj
export function remakeDetail(query) {
  return request({
    url: "/mes/remake/detail/list",
    method: "get",
    params: query,
  });
}

//用料清单查询 2024-12-18  djj
export function workorderBomLinelist(query) {
  return request({
    url: "/mes/pro/workorder/workorderBomLinelist",
    method: "get",
    params: query,
  });
}

//提交复制BOM版本 2024-12-19  djj
export function modifyBomItemCode(data) {
  return request({
    url: "/mes/remake/product/modifyBomItemCode",
    method: "post",
    data: data,
  });
}

/* 2024-12-20 djj 新增 生产工单查询-出库清单 */
export function OutboundSummaryList(query) {
  return request({
    url: "/mes/pro/workorder/OutboundSummaryList",
    method: "get",
    params: query,
  });
}

/* 2024-12-20 djj 新增 生产工单查询-出库清单-物料编码 */
export function OutboundDetailedList(query) {
  return request({
    url: "/mes/pro/workorder/OutboundDetailedList",
    method: "get",
    params: query,
  });
}

/* 2024-12-26 djj 新增 生产工单-成品改制-查询原工单编号 */
export function queryOldWorkorderCode(data) {
  return request({
    url: "/mes/remake/product/queryOldWorkorderCode",
    method: "post",
    data: data,
  });
}

/* 2024-12-26 djj 新增 生产工单-复制BOM版本-直接修改复制BOM版本 */
export function directLyModifyBomItemCode(data) {
  return request({
    url: "/mes/remake/product/directLyModifyBomItemCode",
    method: "post",
    data: data,
  });
}
